package com.cqrt.controller;

import com.cqrt.service.ProjectBoardService;
import com.cqrt.util.PageDtoUtil;
import com.hustcad.plm.rpm.model.dto.active.TyppmActiveTreeDTO;
import com.hustcad.plm.rpm.model.dto.job.TyppmJobDTO;
import com.ty.basic.response.ResponseResult;
import com.ty.ppm.model.constant.ApiPathConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * @Author：lotus
 * @DATE: 2025/7/11 14:34
 */

@RestController
@Api(tags = "项目看板")
@RequestMapping(ApiPathConstant.PARENT_VERSION_ONE_PATH + "board")
public class RTProjectBoardController {

    @Resource
    private ProjectBoardService projectBoardService;

    @GetMapping("/queryProjectCurrent")
    @ApiOperation(value = "我管理的项目", produces = "application/json; charset=utf-8")
    public ResponseResult<PageDtoUtil> queryProjectPageByCurrentUser(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "20") Integer pageSize) {
        return ResponseResult.success(projectBoardService.queryProjectPageByCurrentUser(pageNum, pageSize));
    }

    @PostMapping("/queryActiveTree")
    @ApiOperation(value = "获取一级任务树", produces = "application/json; charset=utf-8")
    public List<TyppmActiveTreeDTO> getLevelOnePlanActiveTreeByPlan(String planOid){
        return projectBoardService.getLevelOnePlanActiveTreePlan(planOid);
    }

    @PostMapping("/queryNotIssuedTask")
    @ApiOperation(value = "等待的项目任务", produces = "application/json; charset=utf-8")
    public ResponseResult<PageDtoUtil> queryNotIssuedTask(@RequestParam(defaultValue = "1") Integer pageNum,
                                                                    @RequestParam(defaultValue = "20") Integer pageSize){
        return ResponseResult.success(projectBoardService.queryNotIssuedTask(pageNum, pageSize));
    }


    @PostMapping("/queryUserTask")
    @ApiOperation(value = "我管理的项目任务", produces = "application/json; charset=utf-8")
    public ResponseResult<PageDtoUtil> queryProjectTask(@RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "20") Integer pageSize){

        return ResponseResult.success(projectBoardService.queryProjectTask(pageNum, pageSize));
    }

    @PostMapping("/checkUserTask")
    @ApiOperation(value = "搜索我管理的项目任务", produces = "application/json; charset=utf-8")
    public PageDtoUtil checkProjectTask(@RequestBody TyppmJobDTO typpmJobDTO,
                                        @RequestParam(defaultValue = "1") Integer pageNum,
                                        @RequestParam(defaultValue = "20") Integer pageSize){

        return projectBoardService.checkProjectTask(typpmJobDTO,pageNum, pageSize);
    }

    @GetMapping("/queryTheWaitingProjectTasks")
    @ApiOperation(value = "等待的项目任务2.0", produces = "application/json; charset=utf-8")
    public ResponseResult queryTheWaitingProjectTasks(@RequestParam(defaultValue = "1") Integer pageNum,
                                                      @RequestParam(defaultValue = "20") Integer pageSize){
        return ResponseResult.success(projectBoardService.queryTheWaitingProjectTasks(pageNum,pageSize));
    }
}

